package com.easymin.weixin.common;

import java.util.Random;

public class CharacterUtils {

  private static final String SECRET_STRING =
      "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

  /**
   * 获取指定长度的随机字符串.
   */
  public static String randomString(int length) {

    Random random = new Random();
    random.setSeed(System.currentTimeMillis());

    StringBuffer sb = new StringBuffer();

    for (int i = 0; i < length; ++i) {



      int number = random.nextInt(SECRET_STRING.length());

      sb.append(SECRET_STRING.charAt(number));
    }

    return sb.toString();
  }
}
